import type { Request, ResponseToolkit } from "@hapi/hapi";
import Hapi from "@hapi/hapi";
import { NoteCate } from "../../model/index";

let route: Hapi.ServerRoute<Hapi.ReqRefDefaults> = {
  path: "/getCate",
  method: "get",
  handler: async (r: any, h: ResponseToolkit) => {
    try {
      let cate = await NoteCate.find();
      return {
        code: 200,
        data: {
          data: cate,
          total: cate.length,
        },
        message: "",
      };
    } catch (err: any) {
      return err;
    }
  },
  options: {
    plugins: {
      "hapi-swagger": {
        security: [{ apiKey: [] }],
      },
    },
    tags: ["api"],
  },
};
export default route;
